import time
'''def deco(func):
    start_time=time.time()
    func()
   
    stop_time=time.time()
    print("the func run time is %s" % (stop_time - start_time))

def test1():
    time.sleep(3)
    print('in the test1')

def test2():
    time.sleep(3)
    print('in the test2')

deco(test1)
deco(test2)'''

'''def deco(func):
    start_time = time.time()
    return func
    stop_time = time.time()
    print("the func run time is %s" % (stop_time - start_time))

def test1():
    time.sleep(3)
    print('in the test1')

def test2():
    time.sleep(3)
    print('in the test2')

test1 = deco(test1)
test1()

test2 = deco(test2)
test2()'''

'''def timer(func):   #timer(test1)  func = test1
    def deco():
        start_time = time.time()
        func()   #run test1
        stop_time = time.time()
        print("the func run time is %s" % (stop_time - start_time))
    return deco   #返回这个函数的内存地址
@timer   #test1 = timer(test1)
def test1():
    time.sleep(3)
    print('in the test1')

@timer   #test2 = timer(test2)  = deco test2()=deco()
def test2():
    time.sleep(3)
    print('in the test2')

# print(timer(test1))   #将内存地址传进去
# ''test1 = timer(test1)
# test1()   #-->deco''
test1()
test2()
'''

def timer(func):   #timer(test1)  func = test1
    def deco(*args,**kwargs):
        start_time = time.time()
        func(*args,**kwargs)   #run test1
        stop_time = time.time()
        print("the func run time is %s" % (stop_time - start_time))
    return deco   #返回这个函数的内存地址
@timer   #test1 = timer(test1)
def test1():
    time.sleep(1)
    print('in the test1')

@timer   #test2 = timer(test2)  = deco test2()=deco()
def test2(name,age):
    time.sleep(1)
    print('test2:',name,age)

test1()
test2('ouyang',22)


